<?php
namespace core\lib;
class Config{
	public static $conf = array();
	//获取配置文件并返回指定下标值 
	public static function get($name,$file){
		if(isset(self::$conf[$file])){
			return self::$conf[$file][$name];
		}else{
			$path = HYYPATH.'/config/'.$file.'.php';
			if(is_file($path)){
				$conf = include $path;
				if(isset($conf[$name])){
					self::$conf[$file] = $conf;
					return $conf[$name];
				}else{
					throw new \Exception('没有这个配置项'.$name);
				}
			}else{
				throw new \Exception('找不到配置文件'.$file);
			}
		}
	}
	//获取配置并返回所有值
	public static function getAll($file){
		if(isset(self::$conf[$file])){
			return self::$conf[$file];
		}else{
			$path = HYYPATH.'/config/'.$file.'.php';
			if(is_file($path)){
				$conf = include $path;
				self::$conf[$file] = $conf;
				return $conf;
			}else{
				throw new \Exception('找不到配置文件'.$file);
			}
		}
	}
}